/*
 * JumpUtils.java
 * business
 *
 * Created by ChenTao on 2017/2/6.
 *
 * Copyright (c) 2017年 yidiandao. All rights reserved.
 */

package com.yidiandao.business.utils;

import android.app.Activity;
import android.content.Context;

import com.yidiandao.business.constant.Intents;
import com.yidiandao.business.constant.ServerType;
import com.yidiandao.business.data.bean.Coupon;
import com.yidiandao.business.data.bean.LinkedMeBean;
import com.yidiandao.business.data.imagemodule.ImageAD;
import com.yidiandao.business.data.imagemodule.Menu;
import com.yidiandao.business.data.imagemodule.Notice;
import com.yidiandao.business.data.response.QueryFrameResponse;
import com.yidiandao.business.data.response.QueryHomeHeaderResponse;
import com.yidiandao.business.data.response.SplashResponse;
import com.yidiandao.business.ui.brandabout.brandgoods.BrandGoodsActivity;
import com.yidiandao.business.ui.brandabout.brandstreet.BrandStreetActivity;
import com.yidiandao.business.ui.dailyquotation.DailyQuotationActivity;
import com.yidiandao.business.ui.goodsdetail.GoodsDetailActivity;
import com.yidiandao.business.ui.loginabout.login.LoginActivity;
import com.yidiandao.business.ui.main.MainActivity;
import com.yidiandao.business.ui.newgoods.NewGoodsActivity;
import com.yidiandao.business.ui.searchabout.categorysearchgoods.CategorySearchGoodsActivity;
import com.yidiandao.business.ui.shop.ShopActivity;
import com.yidiandao.business.ui.shopdetail.ShopDetailActivity;
import com.yidiandao.business.ui.shopdetail.categorygoods.ShopCategoryGoodsActivity;
import com.yidiandao.business.ui.url.UrlActivity;
import com.yidiandao.business.ui.widget.view.BottomBar;

/**
 * 点击跳转的工具类
 * <p>
 * <p>Created by ChenTao(chentao7v@gmail.com) on 2017/2/8 15:15
 */
public class JumpUtils {

    public static void toLoginActivity(Context context) {
        LoginActivity.actionStart(context);
    }

    public static void clickBanner(Activity activity, QueryHomeHeaderResponse.Banner banner) {
        try {
            switch (banner.getType()) {
                case ServerType.Normal.BRAND_DETAIL:
                    BrandGoodsActivity.actionStart(
                            activity, banner.getExtra(), banner.getData(), null);
                    break;
                case ServerType.Normal.CATEGORY_DETAIL:
                    CategorySearchGoodsActivity.actionStart(
                            activity, banner.getData(), banner.getExtra());
                    break;
                case ServerType.Normal.GOODS_DETAIL:
                    GoodsDetailActivity.actionStart(activity, banner.getData());
                    break;
                case ServerType.Normal.SHOP_CATEGORY_DETAIL:
                    ShopCategoryGoodsActivity.actionStart(
                            activity, banner.getExtra(), banner.getSupplierId(), banner.getData());
                    break;
                case ServerType.Normal.SUPPLIER_DETAIL:
                    ShopDetailActivity.actionStart(activity, banner.getData());
                    break;
                case ServerType.Normal.URL:
                    UrlActivity.actionStart(activity, banner.getData());
                    break;
                case ServerType.Normal.ARTICLE:
                    UrlActivity.actionStartForArticle(activity, banner.getData());
                    break;
                case ServerType.Normal.DAILY_QUOTATION:
                    DailyQuotationActivity.actionStart(activity);
                    break;

            }
        } catch (Exception e) {
            LogUtils.e(e);
        }
    }

    /**
     * 点击首页 分类 购物车 我的订单 图片模块
     */
    public static void clickImageAD(Activity activity, ImageAD imageAD) {

        try {
            switch (imageAD.getType()) {
                case ServerType.Normal.BRAND_DETAIL:
                    BrandGoodsActivity.actionStart(activity, imageAD.getExtra(), imageAD.getData(), null);
                    break;
                case ServerType.Normal.CATEGORY_DETAIL:
                    CategorySearchGoodsActivity.actionStart(activity, imageAD.getData(), imageAD.getExtra());
                    break;
                case ServerType.Normal.GOODS_DETAIL:
                    GoodsDetailActivity.actionStart(activity, imageAD.getData());
                    break;
                case ServerType.Normal.SHOP_CATEGORY_DETAIL:
                    ShopCategoryGoodsActivity.actionStart(activity, imageAD.getExtra(), imageAD.getSupplierId(), imageAD.getData());
                    break;
                case ServerType.Normal.SUPPLIER_DETAIL:
                    ShopDetailActivity.actionStart(activity, imageAD.getData());
                    break;
                case ServerType.Normal.URL:
                    UrlActivity.actionStart(activity, imageAD.getData());
                    break;
                case ServerType.Normal.ARTICLE:
                    UrlActivity.actionStartForArticle(activity, imageAD.getData());
                    break;
                case ServerType.Normal.DAILY_QUOTATION:
                    DailyQuotationActivity.actionStart(activity);
                    break;
            }
        } catch (Exception e) {
            LogUtils.e(e);
        }
    }

    /**
     * 点击首页菜单
     */
    public static void clickMenu(Activity activity, Menu menu) {
        try {
            switch (menu.getMenuKey()) {
                case ServerType.Home.Menu.NEW_GOODS_LIST:
                    NewGoodsActivity.actionStart(activity);
                    break;
                case ServerType.Home.Menu.SUPPLIER_LIST:
                    ShopActivity.actionStart(activity);
                    break;
                case ServerType.Home.Menu.BRAND_STREET:
                    BrandStreetActivity.actionStart(activity);
                    break;
                case ServerType.Normal.URL:
                    UrlActivity.actionStart(activity, menu.getMenuUrl());
                    break;
                case ServerType.Home.Menu.SHOPPING_CART:
                    ((MainActivity) activity).toSwitchFragment(BottomBar.SHOPPING_CART);
                    break;
                case ServerType.Home.Menu.USER_CENTER:
                    ((MainActivity) activity).toSwitchFragment(BottomBar.USER_CENTER);
                    break;
                case ServerType.Home.Menu.SIGN:
                    //                    if (!PreferenceUtils.getToken(UIUtils.getContext())
                    //                            .equals(PreferenceUtils.STRING_DEFAULT)) {
                    String string = PreferenceUtils.getString(UIUtils.getContext(), Intents.SIGN_URL, PreferenceUtils.STRING_DEFAULT, false);
                    String url = UrlUtils.jointUrl(string);
                    UrlActivity.actionStartWithoutShareFeature(activity, url);
                    //                    } else {
                    //                        LoginActivity.actionStart(activity);
                    //                    }
                    break;
                case ServerType.Normal.SUPPLIER_DETAIL:
                    ShopDetailActivity.actionStart(activity, menu.getMenuUrl());
                    break;
                case ServerType.Normal.GOODS_DETAIL:
                    GoodsDetailActivity.actionStart(activity, menu.getMenuUrl());
                    break;
                case ServerType.Normal.CATEGORY_DETAIL:
                    CategorySearchGoodsActivity.actionStart(
                            activity, menu.getMenuUrl(), menu.getMenuExtra());
                    break;
                case ServerType.Normal.SHOP_CATEGORY_DETAIL:
                    ShopCategoryGoodsActivity.actionStart(activity, menu.getMenuExtra(), menu.getMenuSupplierId(), menu.getMenuUrl());
                    break;
                case ServerType.Normal.BRAND_DETAIL:
                    BrandGoodsActivity.actionStart(activity, menu.getMenuExtra(), menu.getMenuUrl(), null);
                    break;
                case ServerType.Normal.ARTICLE:
                    UrlActivity.actionStartForArticle(activity, menu.getMenuUrl());
                    break;
                case ServerType.Normal.DAILY_QUOTATION:
                    DailyQuotationActivity.actionStart(activity);
                    break;
            }
        } catch (Exception e) {
            LogUtils.e(e);
        }
    }

    public static void clickNotice(Activity activity, Notice notice) {
        try {
            switch (notice.getType()) {
                case ServerType.Normal.BRAND_DETAIL:
                    BrandGoodsActivity.actionStart(activity, notice.getExtra(), notice.getData(), null);
                    break;
                case ServerType.Normal.CATEGORY_DETAIL:
                    CategorySearchGoodsActivity.actionStart(activity, notice.getData(), notice.getExtra());
                    break;
                case ServerType.Normal.GOODS_DETAIL:
                    GoodsDetailActivity.actionStart(activity, notice.getData());
                    break;
                case ServerType.Normal.SHOP_CATEGORY_DETAIL:
                    ShopCategoryGoodsActivity.actionStart(activity, notice.getExtra(), notice.getSupplierId(), notice.getData());
                    break;
                case ServerType.Normal.SUPPLIER_DETAIL:
                    ShopDetailActivity.actionStart(activity, notice.getData());
                    break;
                case ServerType.Normal.URL:
                    UrlActivity.actionStart(activity, notice.getData());
                    break;
                case ServerType.Normal.ARTICLE:
                    UrlActivity.actionStartForArticle(activity, notice.getData());
                    break;
                case ServerType.Normal.DAILY_QUOTATION:
                    DailyQuotationActivity.actionStart(activity);
                    break;
            }
        } catch (Exception e) {
            LogUtils.e(e);
        }
    }

    /**
     * 点击深度链接
     */
    public static void clickLinked(Activity activity, LinkedMeBean bean) {
        try {
            switch (bean.getType()) {
                case ServerType.LinkedMe.NEW_GOODS:
                    NewGoodsActivity.actionStart(activity);
                    break;
                case ServerType.LinkedMe.SUPPLIER_LIST:
                    ShopActivity.actionStart(activity);
                    break;
                case ServerType.LinkedMe.BRAND_LIST:
                    BrandStreetActivity.actionStart(activity);
                    break;
                case ServerType.LinkedMe.URL:
                    UrlActivity.actionStart(activity, bean.getData());
                    break;
                case ServerType.LinkedMe.HOME:
                    MainActivity.actionStart(activity);
                    ((MainActivity) activity).toSwitchFragment(BottomBar.HOME);
                    break;
                case ServerType.LinkedMe.SIGN:
                    String string = PreferenceUtils.getString(UIUtils.getContext(), Intents.SIGN_URL, PreferenceUtils.STRING_DEFAULT, false);
                    String url = UrlUtils.jointUrl(string);
                    UrlActivity.actionStartWithoutShareFeature(activity, url);
                    break;
                case ServerType.LinkedMe.SUPPLIER_DETAIL:
                    ShopDetailActivity.actionStart(activity, bean.getData());
                    break;
                case ServerType.LinkedMe.GOODS_DETAIL:
                    GoodsDetailActivity.actionStart(activity, bean.getData());
                    break;
                case ServerType.LinkedMe.CATEGORY_DETAIL:
                    CategorySearchGoodsActivity.actionStart(activity, bean.getData(), bean.getExtra());
                    break;
                case ServerType.LinkedMe.SHOP_CATEGORY_DETAIL:
                    ShopCategoryGoodsActivity.actionStart(activity, bean.getExtra(), bean.getSupplierId(), bean.getData());
                    break;
                case ServerType.LinkedMe.BRAND_DETAIL:
                    BrandGoodsActivity.actionStart(activity, bean.getExtra(), bean.getData(), null);
                    break;
                case ServerType.LinkedMe.ARTICLE:
                    UrlActivity.actionStartForArticle(activity, bean.getData());
                    break;
            }
        } catch (Exception e) {
            LogUtils.e(e);
        }
    }

    public static void clickChooseGoods(Activity activity, Coupon bean) {
        try {
            switch (bean.getType()) {
                case ServerType.ChooseGoods.HOME:
                    MainActivity.actionStart(activity);
                    ((MainActivity) activity).toSwitchFragment(BottomBar.HOME);
                    break;
                case ServerType.ChooseGoods.SHOP_DETAIL:
                    ShopDetailActivity.actionStart(activity, bean.getData());
                    break;
                case ServerType.ChooseGoods.GOODS_DETAIL:
                    GoodsDetailActivity.actionStart(activity, bean.getData());
                    break;
                case ServerType.ChooseGoods.BRAND_DETAIL:
                    BrandGoodsActivity.actionStart(activity, bean.getExtra(), bean.getData(), null);
                    break;
            }
        } catch (Exception e) {
            LogUtils.e(e);
        }
    }

    public static void clickSplashAd(SplashResponse.DataBean.PictureInfoBean bean, Activity activity) {
        try {
            switch (bean.getType()) {
                case ServerType.SPLASHTYPE.COMMODITY:
                    DailyQuotationActivity.actionStart(activity);
                    break;
                case ServerType.SPLASHTYPE.URL:
                    UrlActivity.actionStart(activity, bean.getData());
                    break;
                case ServerType.SPLASHTYPE.GOODS_DETAIL:
                    GoodsDetailActivity.actionStart(activity, bean.getData());
                    break;
                case ServerType.SPLASHTYPE.BRAND_DETAIL:
                    BrandGoodsActivity.actionStart(activity, bean.getExtra(), bean.getData(), null);
                    break;
                case ServerType.SPLASHTYPE.ARTICLE:
                    UrlActivity.actionStartForArticle(activity, bean.getData());
                    break;
                case ServerType.SPLASHTYPE.SUPPLIER_DETAIL:
                    ShopDetailActivity.actionStart(activity, bean.getData());
                    break;
                case ServerType.SPLASHTYPE.CATEGORY_DETAIL:
                    CategorySearchGoodsActivity.actionStart(activity, bean.getData(), bean.getExtra());
                    break;
                case ServerType.SPLASHTYPE.SHOP_CATEGORY_DETAIL:
                    ShopCategoryGoodsActivity.actionStart(activity, bean.getExtra(), bean.getSupplierId(), bean.getData());
                    break;
            }
        } catch (Exception e) {
            LogUtils.e(e);
        }
    }

    public static void clickHomeBigImage(QueryFrameResponse.Frame frameData, Activity activity) {
        try {
            switch (frameData.getType()) {
                case ServerType.SPLASHTYPE.COMMODITY:
                    DailyQuotationActivity.actionStart(activity);
                    break;
                case ServerType.SPLASHTYPE.URL:
                    UrlActivity.actionStart(activity, frameData.getData());
                    break;
                case ServerType.SPLASHTYPE.GOODS_DETAIL:
                    GoodsDetailActivity.actionStart(activity, frameData.getData());
                    break;
                case ServerType.SPLASHTYPE.BRAND_DETAIL:
                    BrandGoodsActivity.actionStart(activity, frameData.getExtra(), frameData.getData(), null);
                    break;
                case ServerType.SPLASHTYPE.ARTICLE:
                    UrlActivity.actionStartForArticle(activity, frameData.getData());
                    break;
                case ServerType.SPLASHTYPE.SUPPLIER_DETAIL:
                    ShopDetailActivity.actionStart(activity, frameData.getData());
                    break;
                case ServerType.SPLASHTYPE.CATEGORY_DETAIL:
                    CategorySearchGoodsActivity.actionStart(activity, frameData.getData(), frameData.getExtra());
                    break;
                case ServerType.SPLASHTYPE.SHOP_CATEGORY_DETAIL:
                    ShopCategoryGoodsActivity.actionStart(activity, frameData.getExtra(), frameData.getSupplierId(), frameData.getData());
                    break;
            }
        } catch (Exception e) {
            LogUtils.e(e);
        }
    }
}
